package study.dq.jms.exception;

import org.apache.activemq.ActiveMQConnectionFactory;

import javax.jms.*;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author dongqun
 * @version 1.0
 * @description 类的功能描述
 * @date 2019/10/18 18:15
 */
public class QueueCustomer {

    public QueueCustomer(String username, String password, String borkerUrl){
        try {
            ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(username,password,borkerUrl);
            QueueConnection connection = factory.createQueueConnection();
            QueueSession session = connection.createQueueSession(false, Session.CLIENT_ACKNOWLEDGE);
            Queue queue = session.createQueue("QUEUE_TEST_1");
            QueueReceiver receiver = session.createReceiver(queue);
            receiver.setMessageListener(new MQExceptionListener());
            connection.start();
        } catch (JMSException e) {
            e.printStackTrace();
        }
    }


    public static void main(String[] args) {
        QueueCustomer customer = new QueueCustomer("admin","admin","tcp://127.0.0.1:61616");
    }
}
